package ltg.ibutton.hydroroom;

public class ColorBand implements Comparable<ColorBand> {
	private int min;
	private int max;
	private double lvl;
	
	public ColorBand(String color, double lvl) {
		if(color.equals("violet")) {
			this.min = 390;
			this.max = 410;
		}
		else if(color.equals("blue")) {
			this.min = 465;
			this.max = 485;
		}
		else if(color.equals("green")) {
			this.min = 500;
			this.max = 520;
		}
		else if(color.equals("yellow")) {
			this.min = 570;
			this.max = 590;
		}
		else if(color.equals("orange")) {
			this.min = 590;
			this.max = 610;
		}
		else if(color.equals("red")) {
			this.min = 650;
			this.max = 670;
		}
		else {
			this.min = 0;
			this.max = 0;
		}
		
		this.lvl = lvl;
	}
	
	
	public ColorBand(int min, int max, double lvl) {
		this.min = min;
		this.max = max;
		this.lvl = lvl;
	}

	public int getMin() { return this.min; }
	public int getMax() { return this.max; }
	public double getLvl() { return this.lvl; }
	
	public boolean inBand(int j) { return (this.min <= j && j <= this.max); }
	
	public int compareTo(ColorBand o) {
		if(this.min < o.getMin() || (this.min == o.getMin() && this.max <= o.getMax()))
			return -1;
		if(this.min == o.getMin() && this.max == o.getMax())
			return 0;
		if(this.min > o.getMax() || (this.max > o.getMax()))
			return 1;
		return 0;
	}
}
